{extend name="AdminEx/index" /}

{block name="main"}
        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                 {$title}
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Dashboard</a>
                </li>
                <li>
                    <a href="#">评论管理</a>
                </li>
                <li class="active"> 评论列表 </li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
             <div class="row">
                <div class="col-sm-12">
                <section class="panel">
                <header class="panel-heading">
                    查看评论
                    <span class="tools pull-right">
                        <a href="javascript:;" class="fa fa-chevron-down"></a>
                        <a href="javascript:;" class="fa fa-times"></a>
                     </span>
                </header>
                <div class="panel-body">
                <div class="adv-table editable-table ">
                <div class="clearfix">
                    <div class="btn-group">
                        <a href="{:url('admin/Book/create')}">
                            <button  class="btn btn-primary">Add New <i class="fa fa-plus"></i></button></a>     
                    </div>
                    <div class="btn-group pull-right">
                        <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Tools <i class="fa fa-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="#">Print</a></li>
                            <li><a href="#">Save as PDF</a></li>
                            <li><a href="#">Export to Excel</a></li>
                        </ul>
                    </div>
                </div>
                <div class="space15"></div>
                <table class="table table-striped table-hover table-bordered" id="editable-sample">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>用户名</th>
                    <th>书名</th>
                    <th>内容</th>
                    <th>打分</th>
                    <th>回复谁</th>
                    <th>评论时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>

                {volist name="data" id="v"}
                <tr class="">
                    <td>{$v.id}</td>
                    <td>{$v.uname}</td>
                     <td>{$v.dname}</td>
                    <td style="word-wrap:break-word; width:200px;">{$v.content}</td>
                    <td>{$v.cmt*2}</td>
                    <td>{$v.gname}</td>
                    <td>{$v.ctime}</td>
                    <td>
                        <a data-id="{$v.id}" href="{:url('admin/Comment/edit',['id'=>$v.id])}"><button class="btn btn-info btn-sm" type="button">edit</button></a>
                        <a class="delete" data-id="{$v['id']}" href="javascript:;"><button class="btn btn-danger btn-sm" type="button">Delete</button></a>
                    </td>
                </tr>
                {/volist}

                </tbody>
                </table>
                </div>
                </div>
                </section>
                </div>
                </div>
        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by <a href="http://www.tcode.me/" target="_blank">淘代码</a>
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>
{/block}



{block name="myjs"}
<!--data table-->
{js href="/static/layout/js/data-tables/jquery.dataTables.js"}
{js href="/static/layout/js/data-tables/DT_bootstrap.js"}

<!--script for editable table-->
{js href="/static/layout/js/editable-table.js"}

<!-- END JAVASCRIPTS -->
{js href="/static/admin/js/toastr.min.js"}
<script>
    jQuery(document).ready(function() {
        EditableTable.init();
    });

  $(function(){
    // 设置弹框参数
    toastr.options = {
        closeButton: true,// 是否显示关闭按钮
        progressBar: true,// 实现显示计时条
        timeOut: "3000",  // 自动关闭时间
        positionClass: "toast-top-right" // 提示位置
        // toast-top-full-width 顶端，宽度铺满整个屏幕
        // toast-top-left  顶端左边
    };
});
    // 执行ajax删除
    function delAjax(id,row) {
        $.ajax({
                dataType:'json',
                type: 'delete',
                url: '/comment/'+id+'.html',
                success: function (data) {
                    console.log(data);
                    if (data.status) {
                        toastr.success(data.info);
                        row.remove();
                    }else{
                        toastr.error(data.info,'WARING');
                    }
                },
                error: function (){
                    alert('AJAX 请求出现错误!');
                }
            });
    }

   
</script>
{/block}


